<?php
$this->breadcrumbs = array(
    Yii::t('application', 'Ptbhadarates') => array('index'),
    Yii::t('application', 'Manage'),
);

$this->menu = array(
//	array('label'=>Yii::t('application', 'List {title}', array('{title}'=>Yii::t('application', 'Ptbhadarate'))), 'url'=>array('index')),
    array('label' => Yii::t('application', 'Create {title}', array('{title}' => Yii::t('application', 'Ptbhadarate'))), 'url' => array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$.fn.yiiGridView.update('ptbhadarate-grid', {
		data: $(this).serialize()
	});
	return false;
});
");
?>

<h1><?php echo Yii::t('application', 'Manage {title}', array('{title}' => Yii::t('application', 'Ptbhadarates'))); ?></h1>

<!--
<p>
You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b>
or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.
</p>
-->

<?php echo CHtml::link(Yii::t('application', 'Advanced Search'), '#', array('class' => 'search-button')); ?>
<div class="search-form" style="display:none">
    <?php
    $this->renderPartial('_search', array(
        'model' => $model,
    ));
    ?>
</div><!-- search-form -->


<?php
//echo CHtml::beginForm();
?>
<div class="form">
    <?php
    $form = $this->beginWidget('CActiveForm', array(
        'id' => 'ptbhadarate-grid-form',
        'enableAjaxValidation' => true,
            ));
    ?>

    <?php echo $form->errorSummary($model); ?>
    
    <?php foreach(array('error', 'notice', 'success') as $key): ?>
	        <?php if (Yii::app()->user->hasFlash($key)): ?>
	            <div class="flash-<?php echo $key ?>">
	                <?php echo Yii::app()->user->getFlash($key) ?>
	            </div>
	        <?php endif; ?>
	    <?php endforeach; ?>    
    
    <?php 
//    echo $model->getError('aresidential_6') . "</br>";
//    $attributenames = $model->getSafeAttributeNames();
//    foreach($attributenames as $key=>$value){
//         echo "$key -> $value </br>";        
//    }
//        $errors = $model->getErrors(); 
//        foreach($errors as $ekey=>$error){
//            foreach($error as $key=>$value){
//                echo "$ekey -> $key -> $value </br>";
//            }
//        }
    ?>


    <?php
    $this->widget('zii.widgets.grid.CGridView', array(
        'id' => 'ptbhadarate-grid',
        'dataProvider' => $model->search(),
        'filter' => $model,
        'columns' => array(
//		'idptbhadarate',
//		'aresidential',
//		'acommercial',
//		'bresidential',
//		'bcommercial',
//		'cresidential',
            /*
              'ccommercial',
              'dresidential',
              'dcommercial',
              'idccfyear',
              'idccward',
             */
//                array(
//                  'header'=>Yii::t('application', 'Cczone'),
//                  'value'=> '$data->idccward0->idcczone',
//                  'name' => 'idcczone',
//                  'htmlOptions' => array('width' => '5%', 'style'=>'text-align:center;display:none'),
//                ),
            array(
                'header' => Yii::t('application', 'Cczone'),
                'value' => '$data->idccward0->idcczone0->zonename',
                'htmlOptions' => array('width' => '5%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Ccward'),
                'value' => '$data->idccward0->wardname',
                'htmlOptions' => array('width' => '5%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Aresidential'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]aresidential",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//                'value' => 'CHtml::error($data,\'[$data->idptbhadarate]aresidential\') . CHtml::activeTextField($data,"[$data->idptbhadarate]aresidential",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//                    'value' => 'CHTML::textField("aresidential[$data->idptbhadarate]",$data->aresidential,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
//                array(
//                    'header' => Yii::t('application', 'Aresidential'),
//                    'value' => 'CHTML::textField("aresidential[$data->idptbhadarate]",$data->aresidential,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//                    'type' => 'raw',
//                    'htmlOptions' => array('width' => '10%', 'style'=>'text-align:center'),
//                ),
            array(
                'header' => Yii::t('application', 'Acommercial'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]acommercial",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//                'value' => 'CHTML::textField("acommercial[$data->idptbhadarate]",$data->acommercial,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Bresidential'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]bresidential",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//              'value' => 'CHTML::textField("bresidential[$data->idptbhadarate]",$data->bresidential,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Bcommercial'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]bcommercial",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//              'value' => 'CHTML::textField("bcommercial[$data->idptbhadarate]",$data->bcommercial,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Cresidential'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]cresidential",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
//              /'value' => 'CHTML::textField("cresidential[$data->idptbhadarate]",$data->cresidential,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Ccommercial'),

                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]ccommercial",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',

                //'value' => 'CHTML::textField("ccommercial[$data->idptbhadarate]",$data->ccommercial,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Dresidential'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]dresidential",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                // 'value' => 'CHTML::textField("dresidential[$data->idptbhadarate]",$data->dresidential,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
            array(
                'header' => Yii::t('application', 'Dcommercial'),
                'value' => 'CHtml::activeTextField($data,"[$data->idptbhadarate]dcommercial",array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                //  'value' => 'CHTML::textField("dcommercial[$data->idptbhadarate]",$data->dcommercial,array(\'width\'=>20,\'size\'=>7,\'maxlength\'=>30,\'style\'=>\'text-align:right\'))',
                'type' => 'raw',
                'htmlOptions' => array('width' => '10%', 'style' => 'text-align:center'),
            ),
//		array(
//			'class'=>'CButtonColumn',
//		),
        ),
    ));

echo CHTML::button('Done', array('submit' => Yii::app()->createUrl("ptbhadarate/gridupdate")));
//echo CHtml::endForm();
    ?>
    <div class="row buttons">
<?php //echo CHtml::submitButton($model->isNewRecord ? Yii::t('ptbhadarate', 'Gridupdate') : Yii::t('application', 'Save')); ?>
    </div>

<?php $this->endWidget(); ?>

</div>

<script>
    
    
    <?php 
        $errors = $model->getErrors(); 
        foreach($errors as $ekey=>$error){
            foreach($error as $key=>$value){
                echo "$('#Ptbhadarate_$ekey').attr('class', 'error');";
            }
        }
    ?>

</script>